package com.example.design.函数式编程.a函数对象化;

import java.util.stream.Stream;

public class Sample04 {

    static class Util {
        public boolean isMale(Sample01.Student student) {
            return student.sex.equals("男");
        }

        public String getName(Sample01.Student student) {
            return student.getName();
        }
    }

    public static void main(String[] args) {
        Util util = new Util();

        /**
         * 晒出所有男学生
         */
        Stream.of(
                new Sample01.Student("zhang", "男",1),
                new Sample01.Student("li", "女",11),
                new Sample01.Student("liu", "男",13)
        ).filter(util::isMale).map(util::getName).forEach(System.out::println);
    }
}
